package com.itboye.textileexpes.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.itboye.textileexpes.beans.OfferLineOrderBeans;
import com.itboye.textileexpres.R;
import com.itboye.textileexpres.util.ViewHolder;

public class MyOfflineOrderAdapter extends BaseExpandableListAdapter {
	Context context;
	OfferLineOrderBeans list;

	public MyOfflineOrderAdapter(Context context, OfferLineOrderBeans list) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.list = list;
	}

	@Override
	public int getGroupCount() {
		// TODO Auto-generated method stub
		return list.getList().size();
	}

	@Override
	public int getChildrenCount(int groupPosition) {
		// TODO Auto-generated method stub
		return list.getList().get(groupPosition).getItem().size();
	}

	@Override
	public Object getGroup(int groupPosition) {
		// TODO Auto-generated method stub
		return list.getList().get(groupPosition);
	}

	@Override
	public Object getChild(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return list.getList().get(groupPosition).getItem().get(childPosition)
				.getInfo();
	}

	@Override
	public long getGroupId(int groupPosition) {
		// TODO Auto-generated method stub
		return groupPosition;
	}

	@Override
	public long getChildId(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return childPosition;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public View getGroupView(int groupPosition, boolean isExpanded,
			View convertView, ViewGroup parent) {
		viewHolder holder = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_create_time, null);
		}
		// ViewHolder holder;
		// if (convertView == null) {
		// convertView = LayoutInflater.from(context).inflate(
		// R.layout.list_item, null);
		// holder = new ViewHolder();
		// // holder.Title = (TextView)
		// // convertView.findViewById(R.id.textView1);
		// holder.Release = (TextView) convertView
		// .findViewById(R.id.publish_author_tv);
		//
		// holder.Area = (TextView) convertView.findViewById(R.id.area_tv);
		// holder.Top = (RelativeLayout) convertView.findViewById(R.id.top);
		// convertView.setTag(holder);
		// } else {
		// holder = (ViewHolder) convertView.getTag();
		// }
		// holder.Top.setVisibility(View.VISIBLE);
		// holder.Title.setVisibility(View.GONE);
		// holder.Release.setText(TimeFormat.DateFormat(list.getList()
		// .get(groupPosition).getItem().get(groupPosition)
		// .getCreate_time()));
		// holder.Area
		// .setText(list.getItem().get(groupPosition).getPlace_origin());
		return convertView;
	}

	@Override
	public View getChildView(int groupPosition, int childPosition,
			boolean isLastChild, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.item_offline_order, null);

			holder.Title = (TextView) convertView
					.findViewById(R.id.goods_name1_tv);
			holder.CommodityName = (TextView) convertView
					.findViewById(R.id.goods_name2_tv);
			holder.City = (TextView) convertView
					.findViewById(R.id.goods_detail_tv);
			holder.DataTime = (TextView) convertView
					.findViewById(R.id.tvOfftime);
			holder.Delete = (TextView) convertView.findViewById(R.id.cancle_tv);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		// Log.e("LogOff",
		// list.getList().get(groupPosition).getInfo().get(childPosition).getName()+"");
		// holder.Title.setText(list.getList().get(groupPosition).getItem()
		// .get(groupPosition).getInfo().get(childPosition).getName());
		// holder.CommodityName.setText(list.getList().get(groupPosition)
		// .getItem().get(childPosition).getInfo().get(location));
		// holder.City.setText(list.getList().get(childPosition).getName());
		// holder.DataTime.setText(list.getList().get(childPosition)
		// .getCreate_time());

		return convertView;
	}

	@Override
	public boolean isChildSelectable(int groupPosition, int childPosition) {
		// TODO Auto-generated method stub
		return true;
	}

	class viewHolder {
		LinearLayout lin_create_time;
		ImageView back;
		TextView title;
	}

}
